<%-- 
    Document   : index
    Created on : Dec 3, 2013, 9:42:29 PM
    Author     : Welcome
--%>

<%@page import="bc.entity.Quyen"%>
<%@page import="businesscard.DAO.QuyenDAO"%>
<%@page import="java.util.List"%>
<%@page import="bc.entity.User"%>
<%@page import="businesscard.DAO.UserDAO"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <link rel="stylesheet" href="css/style.css" type="text/css"/>
        <link rel="stylesheet" href="css/bocuc.css" type="text/css"/>
        <link rel="stylesheet" href="css/testcss.css" type="text/css"/>
        <link rel="stylesheet" href="css/mystyle.css" type="text/css"/>
        <link rel="stylesheet" href="css/botoncss.css" type="text/css"/>
        <link rel="stylesheet" href="css/cssadmin.css" type="text/css"/>
        <script type="text/javascript" src="jquery/jquery-1.1.3.1.min.js"></script> 
        <script type="text/javascript" src="jquery/jquery-1.4.2.js"></script> 
        <script type="text/javascript" src="jquery/jquery-latest.js"></script>
        <script type="text/javascript" src="jquery/myjquery.js"></script>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
        <script type="text/javascript" src="jquery/jquery-1.8.0.min.js"></script>
       
 
        <script type="text/javascript">
            $(function() {
                $(".inputsearch").keyup(function()
                {
                    var searchid = $(this).val();
                    var dataString = 'search=' + searchid;
                    if (searchid !== '')
                    {
                        $.ajax({
                            type: "POST",
                            url: "showuserajax.jsp",
                            data: dataString,
                            cache: false,
                            success: function(html)
                            {
                                $("#showhint").html(html).show();
                            }
                        });
                    }else{
                         jQuery("#showhint").hide();
                    }
                    return false;
                });

                jQuery("#showhint").live("click", function(e) {
                    var $clicked = $(e.target);
                    var $name = $clicked.find('.name').html();
                    var decoded = $("<div/>").html($name).text();
                    $('#searchid').val(decoded);
                });
                jQuery(document).live("click", function(e) {
                    var $clicked = $(e.target);
                    if (!$clicked.hasClass("inputsearch")) {
                        jQuery("#showhint").fadeOut();
                    }
                });
                $('#searchid').click(function() {
                    jQuery("#showhint").fadeIn();
                });
                
            });
        </script>
        <style type="text/css">
         //body{ 
         //       font-family:Tahoma, Geneva, sans-serif;
         //       font-size:18px;
         //   }
        //    .content{
        //        width:900px;
        //        margin:0 auto;
        //    }
            .name{
                width:446px;
                
                margin-top:-1px !important;
                background-color:transparent !important;
                margin-left:0;}
            #showhint
            {
                position:absolute;
                width:446px;
                padding:10px;
                display:none;
                margin-top:-1px;
                border-top:0px;
                overflow:hidden;
                border:1px #CCC solid;
                background-color: white;
                margin-left: 423px;
            }
            .show
            {
                padding:10px; 
                border-bottom:1px #999 dashed;
                font-size:15px; 
                height:50px;
            }
            .show:hover
            {
                background:#4c66a4;
                color:#FFF;
                cursor:pointer;
            }
            .name:hover
            {
                background:#4c66a4;
                color:#FFF;
                cursor:pointer;
            }
        </style>
        </script>
        <title>Admin</title>
    </head>
    <body>
        <div class="bodypage">
            <!phan dau cua trang>
            <div class="top">
                <%@include file='header.jsp'%>
            </div>
            <!phan search>
            <div class="khoangcachtrang">
                <div class="searchgroup">

                    <form class="search">
                        <input class="inputsearch"  id="searchid" type="text" name="searchid" value=""  />   
                        <input class="btnsearch" type="submit" value="Tìm" name="btnsearch" />
                        <div id="showhint"></div>
                        
                    </form>

                </div>
            </div>

            <!phan giua trang >
            <div class="centerpage">

                <div class="leftsite">
                    <div class="menuweb">
                        <%@include file='menuleft.jsp' %>
                    </div>
                </div>

                <div class="content">
                    
                    <div class="khoangtrang"></div>

                    <div class="userql">
                        <%
                            UserDAO urdao = new UserDAO();
                            try {
                                QuyenDAO qdao = new QuyenDAO();
                                List<Quyen> q1= qdao.getAllQuyen();
                                for (int i = 1; i <= q1.size(); i++) {
                                   QuyenDAO qdao2 = new QuyenDAO();

                                    Quyen q = qdao2.getQuyenById(i);
                        %>
                        <div class="tenquyen"> <div class="tenquyenx"><%= q.getQuyen()%></div>
                            <div class="daugach"></div>
                            <%
                                List<User> listur = urdao.getUserByQuyen(q);
                                try {
                            %>
                            <table class="danhsach">
                                <thead>
                                <td>STT</td>
                                <td>USER</td>
                                <td>EMAIL</td>
                                <td>SỐ ĐIỆN THOẠI</td>
                                <td>GIỚI TÍNH</td>



                                <td>ACTION</td>

                                </thead>
                                <%
                                    int stt = 1;
                                    for (int j = 0; j < listur.size(); j++) {

                                %>
                                <tr class="thongtinnv">

                                    <td><div class="sttnvad"><%= stt%></div></td>
                                    <td><div class="nhanvienad"><%=listur.get(j).getUser()%> </div></td>
                                    <td><div class="nhanvienad"><%=listur.get(j).getEmail()%> </div></td>
                                    <td><div class="nhanvienad"><%=listur.get(j).getSdt()%> </div></td>
                                    <td><div class="nhanvienad"><%=listur.get(j).getGioitinh()%> </div></td>


                                    <td><form method="POST" action="UserController" class="hoatdong">
                                            <input type="hidden" name="txtiduser" value="<%= listur.get(j).getIdUser()%>"/>
                                            <div class="xoanv"><button type="submit" name="action" value="delete">Xóa</button></div>
                                            <div class="capnhatnv"><button type="submit" name="action" value="detail">Chi tiết</button></div>
                                        </form>
                                    </td>
                                </tr>
                                <%
                                        stt++;
                                    }
                                %>
                            </table>
                            <%
                                        } catch (Exception ex) {
                                            ex.printStackTrace();

                                        }
                                    }
                                } catch (Exception ex) {
                                    ex.printStackTrace();

                                }
                            %>
                        </div>
                    </div>
                    <div class="khoangtrang"></div>

                </div>


            </div>
            <!phan cuoi trang>
            <div class="footer">
                <div class="footerleft"></div>
                <div class="footerright"></div>
            </div>
        </div>
    </body>
</html>
